// index.js
// 获取应用实例
const app = getApp()
import { placeOrder, wxLogin } from '../../api/api'
import { getStorage } from '../../common/utils'

Page({
  data: {
    motto: 'Hello World',
    orderInfo: undefined
  },
  onLoad(option) {
    if(option.data && option.data != 'undefined'){
      let data = option.data != 'undefined' ? JSON.parse(option.data) : undefined;
    
      if(data) {
        this.setData({
          orderInfo: data
        })

        return;
      }
    }
    
    this.getOrderInfo(option.scene);
  },

  getOrderInfo(scene) {
    console.log(scene)
  },
  priceAction() {
    placeOrder((res) => {
      wx.requestPayment({
        timeStamp: res.timeStamp,
        nonceStr: res.nonceStr,
        package: res.package,
        signType: res.signType,
        paySign: res.paySign,
        success (res) {
          console.log(res);
        },
        fail (res) {
          console.log(res);
        }
      })
    })
  }
})
